from numpy import random
import time
# a = list(range(1,100,2))
# gt = a.copy()
# random.shuffle(a)
# print(a)
# print(gt)

class generator:
    def __init__(self, Num=5, length=100, begin=10, step=5) -> None:
        self.sorted_lists = []
        self.test_lists = []
        self.Num = Num
        self.length = length
        be = begin
        for n in range(Num):
            sorted_list = []
            for i in range(length):
                ite = random.randint(be, be+step)
                sorted_list.append(ite)
                be = ite + step
            # 产生乱序的测试集
            test_list = [i for i in sorted_list]
            seeds = int(time.time()) % 909
            random.seed(seeds)

            random.shuffle(test_list)
            self.sorted_lists.append(sorted_list)
            self.test_lists.append(test_list)
            # 为了让测试集看起来足够随机
            seeds = int(time.time()) % 990
            random.seed(seeds)
            be = begin + random.choice(sorted_list) % 10

    def __str__(self) -> str:
        sorted_str = "Sorted set is:\n"
        test_str = "Test set is:\n"

        for i in range(self.Num):
            sorted_str += str(self.sorted_lists[i]) + '\n'
            test_str += str(self.test_lists[i]) + '\n'
            
        return test_str + sorted_str

    def __getitem__(self, index):
        return [self.test_lists[index], self.sorted_lists[index]]

    def output(self):
        # 用于输出测试数据集
        return [self.test_lists, self.sorted_lists]


if __name__ == "__main__":
    a = generator(length=20)
    print(a)
